package operation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

public class Borrow implements IOoperation {
    public void work(Booklist book){
        System.out.println("借阅图书！");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入借阅图书的书名");
        String bookName = sc.nextLine();
        int cnt = book.getCount();
        for (int i = 0; i < cnt; i++) {
            Book book1 = book.getBooks(i);
            if(book1.getName().equals(bookName)){
                if(book1.isBorrowed()==true)
                    System.out.println("该书已借出");
                System.out.println("已借出"+bookName);
                book1.setBorrowed(true);
                return;
            }
        }
    }
}
